package com.ruoyi.game.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.game.domain.GameRobot;
import com.ruoyi.game.service.IGameRobotService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 机器人配置Controller
 * 
 * @author ruoyi
 * @date 2025-04-18
 */
@RestController
@RequestMapping("/game/robot")
public class GameRobotController extends BaseController
{
    @Autowired
    private IGameRobotService gameRobotService;

    /**
     * 查询机器人配置列表
     */
    // @PreAuthorize("@ss.hasPermi('game:robot:list')")
    @GetMapping("/list")
    public TableDataInfo list(GameRobot gameRobot)
    {
        startPage();
        List<GameRobot> list = gameRobotService.selectGameRobotList(gameRobot);
        return getDataTable(list);
    }

    /**
     * 导出机器人配置列表
     */
    // @PreAuthorize("@ss.hasPermi('game:robot:export')")
    @Log(title = "机器人配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GameRobot gameRobot)
    {
        List<GameRobot> list = gameRobotService.selectGameRobotList(gameRobot);
        ExcelUtil<GameRobot> util = new ExcelUtil<GameRobot>(GameRobot.class);
        util.exportExcel(response, list, "机器人配置数据");
    }

    /**
     * 获取机器人配置详细信息
     */
    // @PreAuthorize("@ss.hasPermi('game:robot:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gameRobotService.selectGameRobotById(id));
    }

    /**
     * 新增机器人配置
     */
    // @PreAuthorize("@ss.hasPermi('game:robot:add')")
    @Log(title = "机器人配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GameRobot gameRobot)
    {
        return toAjax(gameRobotService.insertGameRobot(gameRobot));
    }

    /**
     * 修改机器人配置
     */
    // @PreAuthorize("@ss.hasPermi('game:robot:edit')")
    @Log(title = "机器人配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GameRobot gameRobot)
    {
        return toAjax(gameRobotService.updateGameRobot(gameRobot));
    }

    /**
     * 删除机器人配置
     */
    // @PreAuthorize("@ss.hasPermi('game:robot:remove')")
    @Log(title = "机器人配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gameRobotService.deleteGameRobotByIds(ids));
    }
}
